﻿using CommandLine;
using Noria.Frameworks.Eva.Engine;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

[assembly: log4net.Config.XmlConfigurator]

namespace Noria.Frameworks.Eva
{
    class Program
    {
        private static readonly log4net.ILog log = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
        
        static void Main(string[] args)
        {
            Console.WriteLine("Eva -- Code generation tool for NFK -- powered by Miles");
            Console.WriteLine();

            var config = new SimpleConfiguration();
            if (Parser.ParseArgumentsWithUsage(args, config))
            {
                try
                {
                    GenFactory.CreateGenerator(config).Run();
                }
                catch (Exception e)
                {
                    log.Error(e);
                }
            }
        }
    }

    class SimpleConfiguration
    {
        [Argument(ArgumentType.Unique, ShortName = "l", DefaultValue = false, HelpText = "Enable logging or not.")]
        public bool EnableLogging;

        [Argument(ArgumentType.Unique, ShortName = "r", DefaultValue = true, HelpText = "Enable reflection or not.")]
        public bool EnableReflection;

        [Argument(ArgumentType.Required, ShortName = "t", HelpText = "Target generation type.")]
        public Target TargetType;

        [DefaultArgument(ArgumentType.Required, ShortName = "f", HelpText = "Target generation file.")]
        public string TargetFile;

        public enum Target
        {
            Single,
            Project,
            Solution,
        }
    }
}
